<template>
	<div class="seek_pop">
		<el-dialog
			title="查询医嘱信息"
			:visible.sync="dialogVisible"
			width="90%">
			<div class="seek_form clear">
				<div class="seek_factor fl">
					<span class="seek_text" title="门/急/住院号">门/急/住院号</span>
					<span class="seek_val" :title="info.mz_jz_zyh">{{info.mz_jz_zyh}}</span>
				</div>
				<div class="seek_factor fl">
					<span class="seek_text" title="科室名称">科室名称</span>
					<span class="seek_val" :title="info.deptName">{{info.deptName}}</span>
				</div>
				<div class="seek_factor fl">
					<span class="seek_text" title="门诊流水/住院次数">门诊流水/住院次数</span>
					<span class="seek_val" :title="info.mz_jz_zyh">{{info.lsh_num}}</span>
				</div>
				<div class="seek_factor fl">
					<span class="seek_text" title="病人姓名">病人姓名</span>
					<span class="seek_val" :title="info.patientName">{{info.patientName}}</span>
				</div>
				<div class="seek_factor fl">
					<span class="seek_text" title="性别">性别</span>
					<span class="seek_val" :title="info.sex">{{info.sex}}</span>
				</div>
				<div class="seek_factor fl">
					<span class="seek_text" title="年龄">年龄</span>
					<span class="seek_val" :title="info.age">{{info.age}}</span>
				</div>
				<div class="seek_factor fl">
					<span class="seek_text" title="身高/体重">身高/体重</span>
					<span class="seek_val" :title="info.height+'cm/'+info.weight+'kg'">{{info.height}}cm/{{info.weight}}kg</span>
				</div>
				<div class="seek_factor fl">
					<span class="seek_text" title="是否哺乳">是否哺乳</span>
					<span class="seek_val" :title="info.is_brqflag">{{info.is_brqflag}}</span>
				</div>
				<div class="seek_factor fl">
					<span class="seek_text" title="是否妊娠">是否妊娠</span>
					<span class="seek_val" :title="info.is_rsflag">{{info.is_rsflag}}</span>
				</div>
				<div class="seek_factor fl">
					<span class="seek_text" title="妊娠日期">妊娠日期</span>
					<span class="seek_val" :title="info.rs_start_time">{{info.rs_start_time}}</span>
				</div>
				<div class="seek_factor fl">
					<span class="seek_text" title="医保病人">医保病人</span>
					<span class="seek_val" :title="info.ybbr">{{info.ybbr}}</span>
				</div>
				<div class="seek_factor fl">
					<span class="seek_text" title="军人">军人</span>
					<span class="seek_val" :title="info.jun_ren">{{info.jun_ren}}</span>
				</div>
				<div class="seek_factor fl">
					<span class="seek_text" title="肝损程度">肝损程度</span>
					<span class="seek_val" :title="info.gz_tagflag">{{info.gz_tagflag}}</span>
				</div>
				<div class="seek_factor fl">
					<span class="seek_text" title="肾损程度">肾损程度</span>
					<span class="seek_val" :title="info.sz_tagflag">{{info.sz_tagflag}}</span>
				</div>
				<div class="seek_factor fl">
					<span class="seek_text" title="处方医生">处方医生</span>
					<span class="seek_val" :title="info.doctorName">{{info.doctorName}}</span>
				</div>
				<div class="seek_factor fl">
					<span class="seek_text" title="医生编号">医生编号</span>
					<span class="seek_val" :title="info.doctorCode">{{info.doctorCode}}</span>
				</div>
			</div>
			<el-tabs v-model="activeName" @tab-click="handleClick" class="seek_tabs">
			    <el-tab-pane :label="'审查结果（'+examList.length+'）'" name="scjg">
					<Bluetable :tHead="examHead" :tData="examList"></Bluetable>
				</el-tab-pane>
			    <el-tab-pane :label="'用药信息（'+ordersList.length+'）'" name="yyxx">
					<Bluetable :tHead="ordersHead" :tData="ordersList"></Bluetable>
				</el-tab-pane>
			    <el-tab-pane :label="'诊断信息（'+diseaseList.length+'）'" name="zdxx">
					<Bluetable :tHead="diseaseHead" :tData="diseaseList"></Bluetable>
				</el-tab-pane>
			    <el-tab-pane :label="'过敏源信息（'+allergensList.length+'）'" name="gmyxx">
					<Bluetable :tHead="allergensHead" :tData="allergensList"></Bluetable>
				</el-tab-pane>
				<el-tab-pane :label="'审核历史（'+examHistoryList.length+'）'" name="shls">
					<Bluetable :tHead="examHistoryHead" :tData="examHistoryList" @clickFun="clickFun"></Bluetable>
					
				</el-tab-pane>
			</el-tabs>
		</el-dialog>
	</div>
</template>

<script>
	import {ptc} from "@/api/systemport.js";
	export default {
		name:"Queryseekpop",
		props:{
			seekRow : {
				type:Object
			},
			type:{
				type:String
			}
		},
		watch :{
			seekRow () {
				this.getInfo(this.seekRow.id)
			}
		},
		mounted(){

		},
		data () {
			return {
				dialogVisible:false,
				activeName:"scjg",
				info:{
					mz_jz_zyh:"",
					deptName:"",
					lsh_num:"",
					patientName:"",
					sexflag:"",
					age:"",
					height:"",
					weight:"",
					is_brqflag:"",
					is_rsflag:"",
					rs_start_time:"",
					ybbr:"",
					jun_ren:"",
					gz_tagflag:"",
					sz_tagflag:"",
					doctorName:"",
					doctorCode:""
				},
				examHead:[
					{
						label:"序号",
						index:true
					},
					{
						label:"药品名",
						prop:"title"
					},
					{
						label:"警示信息",
						prop:"warning"
					},
					{
						label:"是",
						prop:"slCode_txt"
					},
					{
						label:"详情",
						prop:"abstractDesc",
						width:"400",
						align:"left"
					}
				],
				examList:[],
				ordersHead:[
					{
						label:"成组",
						prop:"tag_txt"
					},
					{
						label:"临时",
						prop:"isTempDrug_txt"
					},
					{
						label:"药品名称",
						prop:"drugName"
					},
					{
						label:"给药途径",
						prop:"routeName"
					},
					{
						label:"每次用量",
						prop:"liang_ciGydw"
					},
					{
						label:"频次",
						prop:"pinci"
					}
				],
				ordersList:[],
				diseaseHead:[
					{
						label:"诊断编码",
						prop:"disCode"
					},
					{
						label:"诊断名称",
						prop:"disName"
					}
				],
				diseaseList:[],
				allergensHead:[
					{
						label:"过敏源编码",
						prop:"allerCode"
					},
					{
						label:"过敏源名称",
						prop:"allerName"
					}
				],
				allergensList:[],
				examHistoryHead:[
					{
						label:"版本信息",
						prop:"banbenflag",
						click:true
					},
					{
						label:"操作时间",
						prop:"exam_time",
						click:true
					},
					{
						label:"审核状态",
						prop:"statuss"
					},
					{
						label:"药师意见/医生执行原因",
						prop:"exam_remark"
					}
				],
				examHistoryList:[],
			}
		},
		methods: {
			handleClick(tab, event) {
				// console.log(tab, event);
			},
			show(){
				this.dialogVisible = true
			},
			async getInfo (patInfoId) {
				let res = await this.$ptc.pharOrderDefaultSeek({
					patInfoId:patInfoId,
					type:this.type
				})
				this.info=res.patInfo;
				this.info.sexflag=res.sex;
				this.info.age=res.age;
				this.info.is_brqflag=res.is_brq==1?"是":"否";
				this.info.is_rsflag=res.is_rs==1?"是":"否";
				this.info.gz_tagflag=res.gz_tag==1?"轻度":(res.gz_tag==2?"中度":"重度");
				this.info.sz_tagflag=res.sz_tag==1?"轻度":(res.sz_tag==2?"中度":"重度");
				let http=process.env.VUE_APP_BASE_API+":"+ptc;
				for(var i=0;i<res.examList.length;i++){
					res.examList[i].abstractDesc="<div style='padding:15px 6px;'>"+res.examList[i].abstractDesc+"</div>"
				}
				this.examList=res.examList;
				for(var i=0;i<res.ordersList.length;i++){
					res.ordersList[i].tag_txt=res.ordersList[i].tag_txt?("<img src='"+http+res.ordersList[i].tag_txt+"'>"):"";
					res.ordersList[i].liang_ciGydw=res.ordersList[i].liang_ci+res.ordersList[i].gydw;
				}
				this.ordersList=res.ordersList;
				this.diseaseList=res.diseaseList;
				this.allergensList=res.allergensList;
				for(var i=0;i<res.examHistoryList.length;i++){
					res.examHistoryList[i].exam_time=this.$utils.timeFormat(res.examHistoryList[i].exam_time);
					res.examHistoryList[i].statuss=res.examHistoryList[i].phar_state_txt+"["+res.examHistoryList[i].phar_cnname+"]";
					res.examHistoryList[i].banbenflag=res.examHistoryList[i].banben?("<span style='color:#409EFF;cursor:pointer;'>"+res.examHistoryList[i].banben+"</span>"):"";
					
				}
				this.examHistoryList=res.examHistoryList;
			},
			clickFun(row){
				this.$emit("clickFun",row);
			}
		}
	}
</script>

<style lang="scss" scoped="scoped">
	.seek_pop{
		padding:0 20px;
		.seek_form{
			font-size:14px;
			line-height:40px;
			border:1px solid #b3d8ff;
			.seek_factor{
				width:25%;
				height:40px;
				display:flex;align-items: center;justify-content: center;
				.seek_text{
					display:inline-block;
					width:45%;
					height:100%;
					background:#ecf5ff;
					color:#409eff;
					text-align:right;
					padding-right:10px;
					overflow: hidden;
					text-overflow:ellipsis;
					white-space: nowrap;
				}
				.seek_val{
					display:inline-block;
					width:50%;
					height:100%;
					color:#333;
					padding-left:10px;
					overflow: hidden;
					text-overflow:ellipsis;
					white-space: nowrap;
				}
			}
		}
		.seek_tabs{
			margin-bottom:20px;
		}
	}
</style>
